package servlets;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import beans.DAOCLassBasket;


public class CatalogueServlet extends HttpServlet {

	private static final long serialVersionUID = 6193729429741162623L;

	public String pageType;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doProccessing(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doProccessing(req, resp);
	}

	private void doProccessing(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{

		pageType = req.getParameter("page");
		
		System.out.println("Query " + req.getQueryString());
		
		if(pageType.equals("addBasket"))
		{
			System.out.println("test1");
			int itemNum = Integer.parseInt(req.getParameter("item"));
			DAOCLassBasket newbean = new DAOCLassBasket();
			newbean.getProduct(itemNum);
		}
		
		RequestDispatcher dispatcher = req.getRequestDispatcher("ShowData.jsp");
		dispatcher.forward(req, resp);
	}

}
